package com.xiangshizhineng.tianzhangzhi.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiangshizhineng.tianzhangzhi.app.common.PagingContext;
import com.xiangshizhineng.tianzhangzhi.app.common.SortingContext;
import com.xiangshizhineng.tianzhangzhi.app.dao.TaskDAO;
import com.xiangshizhineng.tianzhangzhi.app.model.request.PatrolRequest;
import com.xiangshizhineng.tianzhangzhi.app.model.request.TaskRequest;
import com.xiangshizhineng.tianzhangzhi.app.model.response.*;
import com.xiangshizhineng.tianzhangzhi.app.service.TaskService;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Vector;

@Service
@Slf4j
public class TaskServiceImpl extends ServiceImpl<TaskDAO, TaskResponse> implements TaskService {

    @Autowired
    private TaskDAO taskDAO;

    private Map<String, Object> getUnionParams(@NonNull Map<String, Object> params, Vector<SortingContext> scs, PagingContext pc) {
        params.put("pc", pc);
        params.put("scs", scs);
        return params;
    }

    @Override
    public List<TaskResponse> urgeTask(Long id) {
        return taskDAO.urgeTask(id);
    }

    @Override
    public TaskResponse cbTaskDetail(Long id,Long fId) {
        return taskDAO.cbTaskDetail(id,fId);
    }

    @Override
    public TaskResponse cbTaskDetailHis(Long id, Long fId) {
        return taskDAO.cbTaskDetailHis(id,fId);
    }

    @Override
    public List<TaskResponse> tbTask(Long fId) {
        return taskDAO.tbTask(fId);
    }

    @Override
    public int startTask(TaskRequest taskRequest) {
        return taskDAO.startTask(taskRequest);
    }

    @Override
    public int startTaskHis(TaskRequest taskRequest) {
        return taskDAO.startTaskHis(taskRequest);
    }

    @Override
    public String isStart(TaskRequest taskRequest) {
        return taskDAO.isStart(taskRequest);
    }

    @Override
    public String isStartHis(TaskRequest taskRequest) {
        return taskDAO.isStartHis(taskRequest);
    }

    @Override
    public int endTask(PatrolRequest patrolRequest) {
        return taskDAO.endTask(patrolRequest);
    }

    @Override
    public int maxId(String userId) {
        return taskDAO.maxId(userId);
    }

    @Override
    public MesIsMaxIdResponse cbMaxId(String userId) {
        return taskDAO.cbMaxId(userId);
    }

    @Override
    public int isMaxId(String userId) {
        return taskDAO.isMaxId(userId);
    }

    @Override
    public List<String> selectTbId(Long userId,String onPatrol, String patrolled, String toBeInspected) {
        return taskDAO.selectTbId(userId,onPatrol,patrolled,toBeInspected);
    }

    @Override
    public TaskResponse hisTaskDetail(Long id) {
        return taskDAO.hisTaskDetail(id);
    }


    @Override
    public List<UserResponse> selectTz(String xzqdm) {
        return taskDAO.selectTz(xzqdm);
    }

    @Override
    public List<UserResponse> selectTzT(String xzqdm) {
        return taskDAO.selectTzT(xzqdm);
    }

    @Override
    public String selectLevel(Long tbId) {
        return taskDAO.selectLevel(tbId);
    }

    @Override
    public List<String> selectTbIdAll(Long userId) {
        return taskDAO.selectTbIdAll(userId);
    }

    @Override
    public int selectNew(String userId) {
        return taskDAO.selectNew(userId);
    }

    @Override
    public int isHasTask(String userId) {
        return taskDAO.isHasTask(userId);
    }

    @Override
    public int isHasTaskHis(String userId) {
        return taskDAO.isHasTaskHis(userId);
    }

    @Override
    public List<TaskResponse> mainTaskHis(Map<String, Object> params) {
        return taskDAO.mainTaskHis(params);
    }

    @Override
    public IPage<TaskResponse> selectByMyWrapper(Page page, Wrapper<TaskResponse> userWrapper) {
        return taskDAO.selectByMyWrapper(page, userWrapper);
    }

    @Override
    public IPage<TaskResponse> selectByAllWrapper(Page page, Wrapper<TaskResponse> userWrapper) {
        return taskDAO.selectByAllWrapper(page, userWrapper);
    }

    @Override
    public Double sumMj(Wrapper<TaskResponse> taskResponseWrapper){
        return taskDAO.sumMj(taskResponseWrapper);
    }
    @Override
    public List<TaskResponse> allTasks(Wrapper<TaskResponse> taskResponseWrapper) {
        return taskDAO.allTasks(taskResponseWrapper);
    }

    @Override
    public TaskResponse allTasksById(Wrapper<TaskResponse> taskResponseWrapper) {
        return taskDAO.allTasksById(taskResponseWrapper);
    }

    @Override
    public List<CompletionResponse> allChild(Wrapper<DistrictResponse> districtResponseWrapper) {
        return taskDAO.allChild(districtResponseWrapper);
    }

    @Override
    public IPage<TaskResponse> selectCbByMyWrapper(Page page, Wrapper<TaskResponse> userWrapper) {
        return taskDAO.selectCbByMyWrapper(page,userWrapper);
    }

    @Override
    public int allTasksByIdCountMes(Wrapper<TaskResponse> taskResponseWrapper) {
        return taskDAO.allTasksByIdCountMes(taskResponseWrapper);
    }

}
